package com.fzy.modules.goods.service;

import com.fzy.core.common.IDUtils;
import com.fzy.modules.goods.dao.GoodsBrandDao;
import com.fzy.modules.goods.entity.GoodsBrand;
import com.fzy.modules.goods.entity.GoodsCategory;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 品牌操作
 */
@Service
public class GoodsBrandService {
    @Autowired
    GoodsBrandDao goodsBrandDao;
    /**
     * 查询品牌是否有子级品牌
     * */
    public Integer isChildrenBrand(String id){
        return goodsBrandDao.isChildrenBrand(id);
    }
    /**
     * 查询所有品牌（集合结构）
     */
    public List<GoodsBrand> findAll(){
        return goodsBrandDao.findAllList();
    }
    /**
     * 添加品牌
     */
    public Integer save(GoodsBrand goodsBrand){
        // String uuid= UUID.randomUUID().toString().toUpperCase();
        goodsBrand.setId(IDUtils.genItemId());
        if(StringUtils.isEmpty(goodsBrand.getCompanyId())){
            goodsBrand.setCompanyId("4D74E1E4-A129-11E4-9B6A-782BCBD7746B");
        }
        if(StringUtils.isEmpty(goodsBrand.getDataOrg())){
            goodsBrand.setDataOrg("01010001");
        }
        return goodsBrandDao.save(goodsBrand);}
    /**
     * 修改品牌
     */
    public Integer update(GoodsBrand goodsBrand){return goodsBrandDao.update(goodsBrand);}
    /**
     * 删除品牌
     */
    public Integer delete(String id){return goodsBrandDao.delete(id);}
}
